﻿#pragma once
#include "Protocol.h"

namespace HadoopPipes {
  
  //此处必须与org.apache.hadoop.mapred.pipes.BinaryProtocol.MessageType保持一致
  enum MESSAGE_TYPE {START_MESSAGE=0, SET_JOB_CONF=1, SET_INPUT_TYPES=2, RUN_MAP=3, 
                     MAP_ITEM=4, RUN_REDUCE=5, REDUCE_KEY=6, REDUCE_VALUE=7, 
                     CLOSE=8, ABORT=9, AUTHENTICATION_REQ=10,
                     OUTPUT=50, PARTITIONED_OUTPUT=51, STATUS=52, PROGRESS=53, DONE=54,
                     REGISTER_COUNTER=55, INCREMENT_COUNTER=56, AUTHENTICATION_RESP=57};

  inline const char* messagetTypeToString(MESSAGE_TYPE m){
	  switch (m)
	  {
	  case START_MESSAGE:
		  return "START_MESSAGE";
	  case SET_JOB_CONF:
		  return "SET_JOB_CONF";
	  case SET_INPUT_TYPES:
		  return "SET_INPUT_TYPES";
	  case RUN_MAP:
		  return "RUN_MAP";
	  case MAP_ITEM:
		  return "MAP_ITEM";
	  case RUN_REDUCE:
		  return "RUN_REDUCE";
	  case REDUCE_KEY:
		  return "REDUCE_KEY";
	  case REDUCE_VALUE:
		  return "REDUCE_VALUE";
	  case CLOSE:
		  return "CLOSE";
	  case ABORT:
		  return "ABORT";
	  case AUTHENTICATION_REQ:
		  return "AUTHENTICATION_REQ";
	  case OUTPUT:
		  return "OUTPUT";
	  case PARTITIONED_OUTPUT:
		  return "PARTITIONED_OUTPUT";
	  case STATUS:
		  return "STATUS";
	  case PROGRESS:
		  return "PROGRESS";
	  case DONE:
		  return "DONE";
	  case REGISTER_COUNTER:
		  return "REGISTER_COUNTER";
	  case INCREMENT_COUNTER:
		  return "INCREMENT_COUNTER";
	  case AUTHENTICATION_RESP:
		  return "AUTHENTICATION_RESP";
	  default:
		  return "UNKNOWN PROTOCOL";
	  }	  
  }
}